using System;
using System.Collections.Generic;
using System.Text;
using gudusoft.gsqlparser;
using gudusoft.gsqlparser.Units;

namespace getoraclepackagename
{
    class getoraclepackagename
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Initialization,please wait...");
            TGSqlParser parser = new TGSqlParser(TDbVendor.DbVOracle);
            parser.SqlText.Text = "create package emp_actions as procedure hire_emp(empno number); end emp_actions";

            Console.WriteLine("working..");
            int i = parser.Parse();
            if (i == 0)
            {
                TPlsqlStatement stmt = (TPlsqlStatement)parser.SqlStatements[0];
                if (stmt.SqlStatementType == TSqlStatementType.sstplsql_createpackage)
                {
                    TLzPlsql_Package pkg = (TLzPlsql_Package)stmt.Root;
                    TLz_Attr pkgname = pkg._package_name;
                    Console.WriteLine("package name: " + pkgname.AsText);
                }

            }
            else
                Console.WriteLine(parser.ErrorMessages);

        }
    }
}
